<?php include_once ('function/check_login_function.php'); onlyValid(); onlyPatient();?>
<!DOCTYPE html>
<html>
<head>
	<title>Log</title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<link rel="stylesheet" type="text/css" href="">
</head>
<body>
	<div id="wrap">
		<header>
		</header>
		<div id="main">
			<div id="menu">
			</div>
			<div id="content">

				
				<?php if ($user->getRole() === 'patient') {?>
					<?php $datalog_list = $user->getDataLogList(); ?>
					<?php if ($datalog_list !== null) {?>
					<table>
					<tr>
					<th>Type</th>
					<th>Value</th>
					<th>Notes</th>
					<th>Date</th>
					<th></th>
					</tr>
					<?php 
						
							foreach ($datalog_list as $datalog) {
								echo '<tr>';
								echo '<td>' . DataLog::findTypeName($datalog['datalog_type_id']) . '</td>';
								echo '<td>' . $datalog['datalog_value'] . '</td>';
								echo '<td>' . $datalog['datalog_note'] . '</td>';
								echo '<td>' . $datalog['created_at'] . '</td>';
								echo '<td><a href="function/delete_log_function.php?id=' . $datalog['datalog_id'] . '">Delete</a></td>';
								echo '</tr>';
							}
						}
					?>
					<form action="function/enter_log_function.php" method="POST">
					<select id="type" name="type">
					
					<?php 
						$datalogtype_list = DataLog::getDataLogTypeList();
						foreach ($datalogtype_list as $datalogtype) {
							echo '<option value="'.$datalogtype['datalog_type_id'].'">'.ucwords($datalogtype['datalog_type_name']).'</option>'; 
						}
					?>
					</select>						
					<input type="text" id="value" name="value" /> <br />
					<label for="note"> Note: </label> <br />
					<textarea id="note" name="note" rows="4" cols="50"></textarea> <br />
					<input type="submit" name="enter" value="Enter" /> <br /> 
					</form>

				<?php } ?>
	
			</div>
		</div>
		<footer>
			<div id="footer">
				
			</div>
		</footer>
	</div>
</body>